﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Conmmon.attribute
{
    public class CacheActionAttribute : ActionFilterAttribute
    {
        /// <summary>
        /// 缓存请求数据
        /// </summary>
        private Hashtable ht = Hashtable.Synchronized(new Hashtable());

        public override void OnActionExecuting(ActionExecutingContext context)
        {


            //string ActionArguments = JsonConvert.SerializeObject(context.ActionArguments);
            //var request = context.HttpContext.Request;
            //var cacheInfo = ht[request.Path + request.QueryString + ActionArguments];

            //if (cacheInfo != null)
            //{
            //    context.Result = (IActionResult)cacheInfo;
            //    return;
            //}
        }
        public override void OnActionExecuted(ActionExecutedContext context)
        {
            
            //    var a =  context.ActionDescriptor.Parameters;
            //var request = context.HttpContext.Request;
            //ht[request.Path+ request.QueryString] = context.Result;

        }

        public override void OnResultExecuted(ResultExecutedContext context)
        {

        }
        public override void OnResultExecuting(ResultExecutingContext context)
        {

        }

    }
}
